const { DataTypes } = require('sequelize')
const seq = require('../utils/seq')
const moment = require('moment')

/**
 *id 主键
  名称：name String
  图标：icon String
  顺序：order Integer
  类别：type TingInt 1收入/0支出
  用户id：uid UUID
  创建时间：ctime String
  更新时间：mtime String
 */

module.exports = seq.define('account_tag', {
  id: {
    type: DataTypes.UUID,
    primaryKey: true,
    allowNull: false,
    defaultValue: DataTypes.UUIDV4,
    commet: '账目分类id'
  },
  name: {
    type: DataTypes.STRING,
    allowNull: false,
    comment: '名称'
  },
  uid: {
    type: DataTypes.UUID,
    allowNull: false,
    comment: '用户表id'
  },
  icon: {
    type: DataTypes.STRING,
    allowNull: false,
    comment: '图标'
  },
  order: {
    type: DataTypes.INTEGER,
    comment: '顺序'
  },
  type: {
    type: DataTypes.TINYINT,
    allowNull: false,
    comment: '类别（1收入/0支出）'
  },
  ctime: {
    type: DataTypes.STRING,
    defaultValue: moment().format('YYYY-MM-DD HH:mm:ss'),
    comment: '创建时间'
  },
  mtime: {
    type: DataTypes.STRING,
    defaultValue: moment().format('YYYY-MM-DD HH:mm:ss'),
    comment: '更新时间'
  }
})